$(document).ajaxError(function(event,xhr,options,exc){
    if(xhr.status==401){
        location.href = "blog_login.html";
    }
});

$(document).ajaxSend(function(event,xhr,options){
    let userToken = localStorage.getItem("token");
    xhr.setRequestHeader("user_token", userToken);
});

function getUserInfo(url){
    $.ajax({
        type: "get",
        url: url,
        // data:{
        //     userId: localStorage.getItem("loginUserId")
        // }
        success: function(result){
            if(result !=null && result.code==200 && result.data!=null){
                let userInfo = result.data;
                $(".left .card h3").text(userInfo.userName);
                $(".left .card a").attr("href", userInfo.githubUrl);

            }else{
                // TODO 自行补充
            }
        }
    });
}
function logout(){
    localStorage.removeItem("loginUserId");
    localStorage.removeItem("token");
    location.href = "blog_login.html";
}